package com.sudo.boot.admin._sys;

import com.sudo.boot.base.pojo.JsonRes;
import com.sudo.boot.common.constant.sysconfig.RoleConfig;
import com.sudo.boot.mapper.sys.model.bo.sysconfig.SysRoleBoCount;
import com.sudo.boot.service.sys.SysConfigService;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 系统配置
 *
 * @author DayDayUp
 * @datetime 2023-11-15 14:17
 **/
@RestController
@RequestMapping("/sys-config")
public class SysConfigController {
    @Resource
    private SysConfigService sysConfigService;

    /**
     * 获取系统用户配置角色数量
     */
    @GetMapping("getRoleCountConfig")
    public JsonRes<Map<String,Object>> getRoleCountConfig() {
        Map<String, Object> roleCountConfig = sysConfigService.getSysConfigMapByKey(RoleConfig.class);
        return JsonRes.ok(roleCountConfig);
    }

    /**
     * 修改系统用户配置角色数量
     */
    @PostMapping("updateRoleCountConfig")
    public JsonRes<Void> updateRoleCountConfig(@RequestBody @Validated SysRoleBoCount bo) {
        sysConfigService.updateConfigByKey(RoleConfig.class,bo);
        return JsonRes.ok();
    }
}
